package cn.tyoui.mysql;


import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.util.Properties;

public class Conn {

    private Properties properties;

    public Conn() {
        this.conn();
    }

    public DataSource conn() {
        try {
            String path = "db.properties";
            InputStream inStream = this.getClass().getClassLoader().getResourceAsStream(path);
            properties = new Properties();
            properties.load(inStream);
            return DruidDataSourceFactory.createDataSource(properties);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}